package com.baofu.paycore.service.facade.enums;

import com.system.commons.exception.BizServiceException;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

/**
 * 币种
 * <P>
 *     1、人民币
 *     2、港币
 *     3、日元
 *     4、台币
 *     5、欧元
 *     6、泰国铢
 *     7、美元
 * </P>
 * User: LZQ  Date: 2016/04/21 ProjectName: paycore Version: 5.0.0
 */
@Slf4j
@Getter
@AllArgsConstructor
public enum PayCcyEnum {

    CNY("CNY", "156", "人民币"),
    HKD("HKD", "344", "港币"),
    JPY("JPY", "392", "日元"),
    TWD("TWD", "344", "台币"),
    EUR("EUR", "978", "欧元"),
    THB("THB", "764", "泰国铢"),
    USD("USD", "840", "美元");

    /** 类型码 */
    private String code;

    private String number;

    /** 类型描述 */
    private String description;

    /**
     * 通过枚举<code>code</code>获得枚举
     *
     * @param code 枚举编码
     * @return     资金货币类型枚举
     */
    public static PayCcyEnum getByCode(String code) {
        for (PayCcyEnum currency : values()) {
            if (currency.getCode().equals(code)) {
                return currency;
            }
        }
        log.error("不支持的币种:{}",code);
        throw new BizServiceException(PayCoreErrorCode.VALUE_NOT_SUPPORT, "不支持的币种！"+code);
    }
}